JS - element properties - title

revision:


sets or returns the value of the title attribute.

top

This property sets or returns the value of an element's title attribute. The title attribute specifies extra information about an element. It can be shown as a tooltip text when the mouse moves over the element.

Syntax:

element.title : returns the title property: the value of the element's title attribute.

element.title = text : sets the title property.

property value:

text : the value for the element's title attribute.

example

WHO was founded in 1948.

The title of the abbr element is:

code:
                <div>
                    <p><abbr id="Abbr" title="World Health Organization">WHO</abbr> was founded in 1948.</p>
                    <p>The title of the abbr element is: <span id="prop"></span> </p>
                </div>
                <script>
                    const element = document.getElementById("Abbr");
                    document.getElementById("prop").innerHTML = element.title;
                </script>